﻿<?php
// cabinet
	function isValidUser()
	{
		if (!isset($_POST['user']) || !isset($_POST['pass']))
			return false;
			
		if (($_POST['user'] === 'user' && $_POST['pass'] === '123') ||
				($_POST['user'] === 'someone' && $_POST['pass'] === 'pass') )
		{
			session_set_cookie_params(0);
			session_start();
			$_SESSION['loggedIn'] = true;
			return true;
		}
		return false;
	}

//
	include $_SERVER['DOCUMENT_ROOT'] . "/session.php";
	
	if (IsSessionStarted() ||
			($_SERVER['REQUEST_METHOD'] === 'POST') && isValidUser() )
	{
	  include $_SERVER['DOCUMENT_ROOT'] . "/html/cabinet.html";
	}
	else
	{
	  include $_SERVER['DOCUMENT_ROOT'] . "/html/auth.html";
	}
	
?>